package com.filmatchs.filmatchs;

import java.util.HashMap;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.net.Uri;

public class FilmatchsContentProvider extends ContentProvider {

	private static final String DATABASE_NAME = "filmatchs.db";
	private static final int DATABASE_VERSION = 1;

	private static final String NOWPLAYING_TABLE = "nowplaying";

	private static final int NOWPLAYING = 1;
	private static final int NOWPLAYING_ID = 2;

	private static HashMap<String, String> mNowplayingProjectionMap;

	private DatabaseHelper mOpenHelper;

	private static final UriMatcher sUriMatcher;
	static {
		sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
		sUriMatcher.addURI(Filmatchs.AUTHORITY, "nowplaying", NOWPLAYING);
		sUriMatcher.addURI(Filmatchs.AUTHORITY, "nowplaying/#", NOWPLAYING_ID);

		mNowplayingProjectionMap = new HashMap<String, String>();
	}

	public FilmatchsContentProvider() {
	}

	@Override
	public int delete(Uri uri, String selection, String[] selectionArgs) {
		return 0;
	}

	@Override
	public String getType(Uri uri) {
		return null;
	}

	@Override
	public Uri insert(Uri uri, ContentValues values) {
		return null;
	}

	@Override
	public boolean onCreate() {
		return false;
	}

	@Override
	public Cursor query(Uri uri, String[] projection, String selection,
			String[] selectionArgs, String sortOrder) {
		return null;
	}

	@Override
	public int update(Uri uri, ContentValues values, String selection,
			String[] selectionArgs) {
		return 0;
	}

	private class DatabaseHelper extends SQLiteOpenHelper {

		public DatabaseHelper(Context context, String name,
				CursorFactory factory, int version) {
			super(context, name, factory, version);
		}

		@Override
		public void onCreate(SQLiteDatabase db) {
			final String CREATE_NOWPLAYING = "CREATE TABLE " + NOWPLAYING_TABLE + " (_id INT, title TEXT, date INTEGER, image BLOB)";
			db.execSQL(CREATE_NOWPLAYING);
		}

		@Override
		public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
			final String DELETE_NOWPLAYING = "DROP TABLE IF EXISTS "
					+ NOWPLAYING_TABLE;
			db.execSQL(DELETE_NOWPLAYING);
			onCreate(db);
		}

	}

}
